package com.globalwave.pos.user.service;


import static junit.framework.Assert.*;

import org.junit.Test;

import com.globalwave.common.exception.BusinessException;
import com.globalwave.system.entity.ShopProfile;
import com.globalwave.system.entity.TerminalProfile;
import com.globalwave.system.entity.User;


public class LoginTest extends PosBaseTestCase {

	
	@Test
	public void login() throws Exception {
		User u = new User() ;
		u.setUser_id(-1L) ;
		u.setLogin_id("admin") ;
		u.setPassword_("admin") ;
		u.setName_("admin") ;
		this.jdbcDao.insert(u) ;
	}
	
	private void assertStatus(String s1status, String t1status, String t2status) throws Exception {
		
		ShopProfile s = getShopProfileService().get(regionCode, shopCode) ;
		assertEquals(s1status, s.getStatus_()) ;
		
		TerminalProfile t = getTerminalProfileService().get(regionCode, terminalCode) ;
		assertEquals(t1status, t.getStatus_()) ;
		
		t = getTerminalProfileService().get(regionCode, terminalCodeR2) ;
		assertEquals(t2status, t.getStatus_()) ;
	}

	private TerminalProfile getTerminalProfileR1() throws Exception {
		TerminalProfile e = new TerminalProfile() ;
		e.setRegion_code(regionCode) ;
		e.setCode_(terminalCode) ;
		e.setSale_date(getDate("20101001")) ;
		e.setComputer_ip("192.168.0.99") ;
		e.setComputer_name("Test XP") ;
		return e ;
	}

	private TerminalProfile getTerminalProfileR2() throws Exception {
		TerminalProfile e = new TerminalProfile() ;
		e.setRegion_code(regionCode) ;
		e.setCode_(terminalCodeR2) ;
		e.setSale_date(getDate("20101001")) ;
		e.setComputer_ip("192.168.0.98") ;
		e.setComputer_name("Test XP-2") ;
		return e ;
	}

	
	private User getUserRT010078() {
		User e = new User() ;
		e.setRegion_code(regionCode) ;
		e.setLogin_id(userId) ;
		e.setShop_code(shopCode);

		return e ;
		
	} 
	
	private User getUserRT010079() {
		User e = new User() ;
		e.setRegion_code(regionCode) ;
		e.setLogin_id("RT010079") ;
		e.setShop_code(shopCode);

		return e ;
		
	} 
	

	private ShopProfile getShopRT01() throws Exception {
		ShopProfile e = new ShopProfile() ;
		e.setRegion_code(regionCode) ;
		e.setCode_(shopCode) ;
		e.setSale_date(getDate("20101001")) ;
		return e ;
	}
}
